package ex1.game.players;

import ex1.game.Action;
import ex1.game.Player;
import ex1.game.PrisonersDilemmaGame;
import ex1.utils.Utils;

public class NaiveProberPlayer implements Player {

	private double _deffectProb = 0.1;
	
	@Override
	public Action playGame(PrisonersDilemmaGame game,
			Action otherPlayerLastAction) {
				
		if(otherPlayerLastAction == null)
		{
			return Action.Cooperate;
		}
		else
		{
			if((otherPlayerLastAction == Action.Cooperate) && (Utils.RandomGenerator().nextDouble() < _deffectProb))
			{
				return Action.Deffect;
			}
			
			return otherPlayerLastAction;
		}
	}
	
	@Override
	public String toString()
	{
		return "NaiveProberPlayer";
	}

}
